/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.myapp.struts;

import javax.servlet.http.HttpServletRequest;
import entidades.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionMessage;

/**
 *
 * @author Claudia
 */
public class RegistrarseForm extends org.apache.struts.action.ActionForm {

    private String email;
    private String userId;
    private String clave;

    public String getClave() {
        return clave;
    }

    public void setClave(String clave) {
        this.clave = clave;
    }

    public String getUserId() {
        return userId;
    }

    public void setUserId(String userId) {
        this.userId = userId;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }




    public RegistrarseForm() {
        super();
        // TODO Auto-generated constructor stub
    }

    /**
     * This is the action called from the Struts framework.
     * @param mapping The ActionMapping used to select this instance.
     * @param request The HTTP Request we are processing.
     * @return
     */ 
    public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) {
        ActionErrors errors = new ActionErrors();

        if (getUserId() == null || getUserId().length() != 5 ) {
            errors.add("userId", new ActionMessage("error.nombreVacio"));
            // TODO: add 'error.name.required' key to your resources
        }

        if(getClave()== null || getClave().equals(""))
        {
            errors.add("clave", new ActionMessage("error.claveVacio"));
        }
       if(getEmail()== null || getEmail().equals(""))
        {
            errors.add("email", new ActionMessage("error.emailVacio"));
        }
        return errors;
    }
}

